package keeto.com.vn.classified.utils;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Random;
import java.util.Vector;

import keeto.com.vn.classfied.model.Area;
import keeto.com.vn.classfied.model.Category;
import keeto.com.vn.classified.ui.R;
import android.content.Context;

public class Utils {

	public static String[] getTextofCategory(Context context,
			Vector<Category> categories) {

		String[] array = new String[categories.size() + 1];
		array[0] = context.getResources().getString(R.string.choose_category);
		if (categories == null || categories.size() == 0) {
			return array;
		}

		for (int i = 1; i <= categories.size(); ++i) {
			array[i] = categories.get(i-1).getName();
		}

		return array;
	}

	public static String[] getTextofSubCategory(Context context,
			Vector<Category> categories) {

		String[] array = new String[categories.size() + 1];
		array[0] = context.getResources().getString(
				R.string.choose_sub_category);
		if (categories == null || categories.size() == 0) {
			return array;
		}

		for (int i = 1; i <= categories.size(); ++i) {
			array[i] = categories.get(i - 1).getName();
		}

		return array;
	}

	public static String[] getTextofArea(Vector<Area> areas) {

		if (areas == null || areas.size() == 0) {
			return null;
		}
		String[] array = new String[areas.size()];
		
		for (int i = 0; i < areas.size();i++) {
			array[i] = areas.get(i).getName();
		}
		return array;
	}

	public static String getCurrentTime() {
		String time = "";
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Calendar cal = Calendar.getInstance();
		time = dateFormat.format(cal.getTime());
		return time;
	}



}
